/*
 * Created on 2007��5��21��, ����10:18
 * Ԫ��������ڵ��¼
 */

package com.XSQS.storage.record;

/**
 *
 * @author Jofee.Chan
 */
public class ERecord implements Record{
    
    private int sIndex;
    private int eIndex;
    private int level;
    private int type;
    private int nameID;
    private int parent;
    private int firstChild;
    private int sibling;
    
    /** Creates a new instance of ERecord */
    public ERecord() {
    }

    public ERecord(short[] record){
        setRecord(record);
    }
    
    public int[] getRecord(){
        int[] record = new int[8];
        record[0] = sIndex;
        record[1] = eIndex;
        record[2] = level;
        record[3] = type;
        record[4] = nameID;
        record[5] = parent;
        record[6] = firstChild;
        record[7] = sibling;
        return record;
    }
    
    public void setRecord(short[] record){
        if(record.length == 8){
            sIndex = record[0];
            eIndex = record[1];
            level = record[2];
            type = record[3];
            nameID = record[4];
            parent = record[5];
            firstChild = record[6];
            sibling = record[7];
        }else{
            System.err.println("Invalid Param!! Array Size: " + record.length);
        }
    }
    
    public String toString(){
        StringBuffer sb = new StringBuffer();
        sb.append(sIndex + " | ");
        sb.append(eIndex + " | ");
        sb.append(level + " | ");
        sb.append(type + " | ");
        sb.append(nameID + " | ");
        sb.append(parent + " | ");
        sb.append(firstChild + " | ");
        sb.append(sibling);
        return sb.toString();
    }
    
    public int getSIndex() {
        return sIndex;
    }

    public void setSIndex(int sIndex) {
        this.sIndex = sIndex;
    }

    public int getEIndex() {
        return eIndex;
    }

    public void setEIndex(int eIndex) {
        this.eIndex = eIndex;
    }

    public int getLevel() {
        return level;
    }

    public void setLevel(int level) {
        this.level = level;
    }

    public int getType() {
        return type;
    }

    public void setType(int type) {
        this.type = type;
    }

    public int getNameID() {
        return nameID;
    }

    public void setNameID(int nameID) {
        this.nameID = nameID;
    }

    public int getParent() {
        return parent;
    }

    public void setParent(int parent) {
        this.parent = parent;
    }
    
    public int getFirstChild() {
        return firstChild;
    }

    public void setFirstChild(int firstChild) {
        this.firstChild = firstChild;
    }

    public int getSibling() {
        return sibling;
    }

    public void setSibling(int sibling) {
        this.sibling = sibling;
    }

    public int getOffset() {
        return -1;
    }

    public int getLength() {
        return -1;
    }
    
}
